
#include "stdafx.h"
#include "AppWinMFC.h"
#include "UserDefinedPropertyDlg.h"


// CUserDefinedPropertyDlg dialog

IMPLEMENT_DYNAMIC(CUserDefinedPropertyDlg, CDialog)

CUserDefinedPropertyDlg::CUserDefinedPropertyDlg(CWnd* pParent, int objtype)
	: CDialog(CUserDefinedPropertyDlg::IDD, pParent)
{
 m_ObjectType = objtype;
 m_TypeName = "boolean";
 m_Name = "<Enter a Name>";
}

CUserDefinedPropertyDlg::~CUserDefinedPropertyDlg()
{
}

void CUserDefinedPropertyDlg::DoDataExchange(CDataExchange* pDX)
{
  CDialog::DoDataExchange(pDX);
  DDX_Control(pDX, IDC_USERDEFPROPTYPE, m_PropertyType);
  DDX_Control(pDX, IDC_USERDEFPROPNAME, m_PropertyName);
}


BEGIN_MESSAGE_MAP(CUserDefinedPropertyDlg, CDialog)
END_MESSAGE_MAP()


// CUserDefinedPropertyDlg message handlers

BOOL CUserDefinedPropertyDlg::OnInitDialog()
{
  CDialog::OnInitDialog();

  StringVector list;
  theApp.m_OgitorsRoot->GetCustomPropertyList(m_ObjectType,list);
  for(unsigned int i = 0;i < list.size();i++)
  {
	m_PropertyType.AddString(CString(list[i].c_str()));
  }

  m_PropertyType.SelectString(-1, CString(m_TypeName.c_str()));
  m_PropertyName.SetWindowText(CString(m_Name.c_str()));
  return TRUE;  
}

void CUserDefinedPropertyDlg::OnOK()
{
  TCHAR buffer[1000];
//   m_PropertyType.GetWindowText(buffer,1000);
//   m_TypeName = ConvertToApoString(buffer);
//   m_PropertyName.GetWindowText(buffer,1000);
//   m_Name = ConvertToApoString(buffer);
//   StringUtil::trim(m_Name,true,true);
//   if(m_Name == "")
//   {
//    AfxMessageBox(_T("Name can not be empty!"),MB_OK);
//    return;
//   }
//   if(theApp.m_OgitorsRoot->GetSelected()->HasCustomProperty(m_Name))
//   {
//    AfxMessageBox(_T("A property with the same name already exists!"),MB_OK);
//    return;
//   }
//  
  CDialog::OnOK();
}
